{% extends "personal_center/base.html" %}

{% block page_link %}
    <link rel="stylesheet" href="../../static/system_setup/css/style.css">
    <link rel="stylesheet" href="../../static/public_file/css/DepartmentSelection.css">
    <link rel="stylesheet" href="../../static/public_file/css/PersonnelChooser.css">
{% endblock %}


{% block style %}
    <style>
        .add_class {
            background: #1E90FF;
        }
        .performance {
            width: 100%;height: 40px;line-height: 40px;padding-left: 10px;border-bottom: #999999 dashed 1px;cursor: pointer;
        }
        .performance_active {
            background: #2db7f5;color: white;border-bottom: #2db7f5 dashed 1px;
        }
        .file {
            position: relative;display: inline-block;background: #D0EEFF;border: 1px solid #99D3F5;border-radius: 4px;padding: 4px 12px;overflow: hidden;color: #1E88C7;text-decoration: none;text-indent: 0;line-height: 20px;
        }
        .file input {
            position: absolute;font-size: 100px;right: 0;top: 0;opacity: 0;
        }
        .file:hover {
            background: #AADFFD;border-color: #78C3F3;color: #004974;text-decoration: none;
        }
        .shade {
            position: fixed;top: 0;left: 0;right: 0;bottom: 0;background-color: rgba(36, 36, 36, 0.5);display: none;z-index: 10000;
        }
        #processed div {
            padding-left: 2%;
        }
        #processed div:hover {
            background: #cfcfcf;
        }
        #ThreeNavigation div {
            padding-left: 2%;
        }
        #page-footer {
            float: right;height: 40px;padding-top: 5px;text-align: right;padding-right: 2%;
        }
        .regular {
            display: inline-block;vertical-align: top;width: 60px;border-radius: 3px;background: white;border: #cfcfcf solid 1px;height: 30px;line-height: 29px;text-align: center;cursor: pointer;
        }
        .page-list div:hover {
            background: #cfcfcf;color: #0b0b0b;
        }
        .footer-active {
            width: 30px;height: 30px;line-height: 29px;border: #1890ff solid 1px;text-align: center;border-radius: 3px;cursor: pointer;display: inline-block;vertical-align: top;background: #1890ff;color: white;
        }
        .footer {
            width: 30px;height: 30px;line-height: 29px;border: #cfcfcf solid 1px;text-align: center;border-radius: 3px;cursor: pointer;background: white;display: inline-block;vertical-align: top;
        }
        .regular:hover {
            background: #cfcfcf;
        }
        .table_wrap {
            width: 100%;height: 90.5%;overflow: auto;border: #cecece solid 1px;border-left: none;
        }
        .table_wrap table {
            width: 100%;border-collapse: collapse;
        }
        #table {
            width: 100%;border-collapse: collapse;
        }
        #table td {
            height: 35px;line-height: 35px;border: #cecece solid 1px;font-size: 12px;
        }
        #table thead tr th {
            position: sticky;top: 0;background: #EEEEEE;text-align: center;height: 35px;line-height: 35px;border-right: #cecece solid 1px;border-left: #cecece solid 1px;font-size: 12px;font-weight: normal;
        }
        #table th:last-child,
        #table td:last-child {
            position: sticky;text-align: center;right: 0;width: 100px;background: white;box-shadow: -5px 0 5px #b81900;
        }
        #table tbody tr:nth-child(odd) {
            background: #F7F7F7;
         }
        #table tbody tr:hover {
            background: #EFFBFE;
        }
        #table th:last-child {
            z-index: 3;background: #F4F4F5;
        }
        #table .shadow-right th:last-child::after,
        #table .shadow-right td:last-child::after {
            content: "";position: absolute;top: 0;width: 10px;height: 100%;left: -10px;background: linear-gradient(to left, #cfcfcf, transparent);
        }
        .text-version {
            width: 100%;text-align: center;padding-left: 3px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;
        }
        .top_class {
            width: 100px;height: 40px;line-height: 40px;text-align: center;display: inline-block;vertical-align: top;cursor: pointer;
        }
        .top_class_active {
            width: 100px;height: 40px;line-height: 40px;text-align: center;display: inline-block;vertical-align: top;cursor: pointer;color: #2db7f5;border-bottom: #2db7f5 solid 1px;
        }
    </style>
{% endblock %}


{% block right_content %}
    <div style="width: 15%;height: 95%;margin-top: 1.25%;display: inline-block;vertical-align: top;background: white;border: #cfcfcf solid 1px;margin-left: 1%;">
        <div onclick="choose_performance_type(this, 1)" class="performance" {% if my_add == 'true' %}style="color: red;"{% endif %}>
            我添加的
        </div>
        <div onclick="choose_performance_type(this, 2)" class="performance" {% if oversight == 'true' %}style="color: red;"{% endif %}>
            我负责的
        </div>
        <div onclick="choose_performance_type(this, 3)" class="performance" {% if my_do == 'true' %}style="color: red;"{% endif %}>
            我的待办
        </div>
        <div onclick="choose_performance_type(this, 4)" class="performance performance_active">
            我的已办
        </div>
        {% if report_flag == 'true' %}
            <div onclick="choose_performance_type(this, 5)" class="performance">
                工作报表
            </div>
        {% endif %}
    </div>

    <div style="width: 82%;height: 95%;margin-top: 1.25%;display: inline-block;vertical-align: top;background: white;border: #cfcfcf solid 1px;margin-left: 0.5%;">
        <div style="width: 100%;height: 100%;" id="performance_allocation">
            <div style="width: 100%;height: 40px;padding-left: 10px;padding-right: 10px;">
                <div style="height: 40px;float: right;padding-right: 1%;width: 60%;text-align: right;">
                    <div style="width: 150px;line-height: 40px;height: 40px;display: inline-block;vertical-align: top;">
                        <p style="width: 70px;height: 25px;background: #b9378b;margin-top: 7.5px;display: inline-block;vertical-align: top;border-radius: 2px;"></p><p style="display: inline-block;vertical-align: top;">&nbsp;中止</p>
                    </div>

                    <div style="width: 150px;line-height: 40px;height: 40px;display: inline-block;vertical-align: top;">
                        <p style="width: 70px;height: 25px;background: #cfcfcf;margin-top: 7.5px;display: inline-block;vertical-align: top;border-radius: 2px;"></p><p style="display: inline-block;vertical-align: top;">&nbsp;已完结</p>
                    </div>

                    <div style="width: 150px;line-height: 40px;height: 40px;display: inline-block;vertical-align: top;">
                        <p style="width: 70px;height: 25px;background: #0abb78;margin-top: 7.5px;display: inline-block;vertical-align: top;border-radius: 2px;"></p><p style="display: inline-block;vertical-align: top;">&nbsp;待处理</p>
                    </div>

                    <div style="width: 150px;line-height: 40px;height: 40px;display: inline-block;vertical-align: top;">
                        <p style="width: 70px;height: 25px;background: #0b0b0b;margin-top: 7.5px;display: inline-block;vertical-align: top;border-radius: 2px;"></p><p style="display: inline-block;vertical-align: top;">&nbsp;进行中</p>
                    </div>
                </div>
            </div>
            <div class="table_wrap">
                <table id="table" style="width: 100%;{% if not DailyList|length %}height: 100%;{% endif %}">
                    <thead>
                        <tr id="thead-title" style="width: 100%;">
                            <th style="width: 50px;background: #EEEEEE;border-left: none;">序号</th>
                            <th style="width: 300px;">工作来源</th>
                            <th style="width: 150px;">责任科室</th>
                            <th style="width: 100px;">负责人</th>
                            <th style="width: 200px;">开始时间</th>
                            <th style="width: 200px;">结束时间</th>
                            <th style="width: 100px;background: #EEEEEE;border-right: none;">操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% if DailyList|length %}
                            {% for datum in DailyList %}
                                <tr style="width: 100%;{% if datum.appove == "true" %}color: #0abb78;{% else %}{% if datum.state == 'end' %}color: #cfcfcf;{% elif datum.state == 'stop' %}color: #b9378b;{% else %}color: #0b0b0b;{% endif %} {% endif %}">
                                    <td title="{{ datum.Serial }}" style="border-left: none;"><div class="text-version">{{ datum.Serial }}</div></td>
                                    <td title="{{ datum.title }}"><div class="text-version">{{ datum.title }}</div></td>
                                    <td title="{{ datum.company }}"><div class="text-version">{{ datum.company }}</div></td>
                                    <td title="{{ datum.responsible_person }}"><div class="text-version">{{ datum.responsible_person }}</div></td>
                                    <td title="{{ datum.start_time }}"><div class="text-version">{{ datum.start_time }}</div></td>
                                    <td title="{{ datum.end_time }}"><div class="text-version">{{ datum.end_time }}</div></td>
                                    <td style="border-right: none;"><div class="text-version" style="cursor: pointer;" onclick="views_detail('{{ datum.id }}')">查看</div></td>
                                </tr>
                            {% endfor %}
                        {% else %}
                            <tr style="width: 100%;height: 100%;">
                                <td colspan="9" style="width: 100%;height: 100%;text-align: center;line-height: 100%;border: none;">
                                    暂无数据
                                </td>
                            </tr>
                        {% endif %}
                    </tbody>
                </table>
            </div>

            <div style="width: 100%;height: 40px;background: #EEEEEE;border: #cfcfcf solid 1px;border-top: none;border-left: none;">
                <div style="float: left;height: 40px;padding-top: 5px;width: 40%;">
                    <div style="display: inline-block;vertical-align: top;height: 30px;line-height: 30px;padding-left: 3%;font-size: 12px;">
                        此页显示 {{ views_range_start }}-{{ views_range_end }} 条 &nbsp;&nbsp;&nbsp;共 {{ totals }} 条
                    </div>
                </div>
                <div id="page-footer">
                    <div style="display: inline-block;vertical-align: top;text-align: right;">
                        {% if pages > 1 %}
                            <div class="regular" onclick="change_page_size(1)">首页</div>
                            <div class="regular" onclick="change_page_size({{ pages }} - 1)">上一页</div>
                        {% else %}
                            <div class="regular" style="cursor: no-drop;">首页</div>
                            <div class="regular" style="cursor: no-drop;">上一页</div>
                        {% endif %}
                    </div>

                    <div class="page-list" style="display: inline-block;vertical-align: top;">
                        {% for page in page_list %}
                            {% if pages == page %}
                                <div onclick="change_page_size({{ page }})" class="footer-active">{{ page }}</div>
                            {% else %}
                                <div onclick="change_page_size({{ page }})" class="footer">{{ page }}</div>
                            {% endif %}
                        {% endfor %}
                    </div>

                    <div style="display: inline-block;vertical-align: top;text-align: right;">
                        {% if page_all_number > pages %}
                            <div class="regular" onclick="change_page_size({{ pages }} + 1)">下一页</div>
                            <div class="regular" onclick="change_page_size({{ page_all_number }})">尾页</div>
                        {% else %}
                            <div class="regular" style="cursor: no-drop;">下一页</div>
                            <div class="regular" style="cursor: no-drop;">尾页</div>
                        {% endif %}
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div id="job_detail" class="shade">
        <div id="job_models" style="width: 100%;height: 100%;position: absolute;">
            <div id="this_div" style="width: 800px;background: white;z-index: 10000;position: absolute;top: 50%;left: 50%;transform:translate(-50%,-50%);border-radius: 3px;border: #dfdfdf solid 1px;">
                <div id="job_models_title" style="width: 100%;height: 40px;background: white;cursor: move;border-top-left-radius: 5px;border-top-right-radius: 5px;border-bottom: #cfcfcf solid 1px;">
                    <div style="width: 80%;height: 40px;display: inline-block;vertical-align: top;">
                        <div id="top_detail" class="top_class top_class_active" onclick="change_top('1')">详情</div>
                        <div id="top_flow" class="top_class" onclick="change_top('2')">流程图</div>
                    </div>
                    <span onclick="close_job_detail()" style="float: right;line-height: 40px;padding-right: 2%;cursor: pointer;"><i class="iconfont icon-quchu"></i></span>
                </div>

                <div id="flow_detail" style="width: 100%;border-bottom: #cfcfcf solid 1px;padding-bottom: 20px;padding-left: 3%;margin: 0;min-height: 600px;max-height: 700px;overflow: auto;padding-top: 20px;">
                    <table style="width: 94%;">
                        <tr>
                            <td style="width: 10%;height: 35px;border: #DFDFDF solid 1px;background: #F5F5F5;padding-left: 3px;color: #999999;text-align: center;">工作来源</td>
                            <td colspan="3" style="width: 90%;height: 35px;border: #DFDFDF solid 1px;padding-left: 3px;" id="title_detail"></td>
                        </tr>
                        <tr>
                            <td style="width: 10%;height: 35px;border: #DFDFDF solid 1px;background: #F5F5F5;padding-left: 3px;color: #999999;text-align: center;">责任科室</td>
                            <td style="width: 40%;height: 35px;border: #DFDFDF solid 1px;padding-left: 3px;" id="company_detail"></td>
                            <td style="width: 10%;height: 35px;border: #DFDFDF solid 1px;background: #F5F5F5;padding-left: 3px;color: #999999;text-align: center;">责任人</td>
                            <td style="width: 40%;height: 35px;border: #DFDFDF solid 1px;padding-left: 3px;" id="responsible_person_detail"></td>
                        </tr>
                        <tr>
                            <td style="width: 10%;height: 35px;border: #DFDFDF solid 1px;background: #F5F5F5;padding-left: 3px;color: #999999;text-align: center;">开始时间</td>
                            <td style="width: 40%;height: 35px;border: #DFDFDF solid 1px;padding-left: 3px;" id="start_time_detail"></td>
                            <td style="width: 10%;height: 35px;border: #DFDFDF solid 1px;background: #F5F5F5;padding-left: 3px;color: #999999;text-align: center;">结束时间</td>
                            <td style="width: 40%;height: 35px;border: #DFDFDF solid 1px;padding-left: 3px;" id="end_time_detail"></td>
                        </tr>
                        <tr>
                            <td style="width: 10%;height: 35px;border: #DFDFDF solid 1px;background: #F5F5F5;padding-left: 3px;color: #999999;text-align: center;">工作描述</td>
                            <td colspan="3" style="width: 90%;height: 35px;border: #DFDFDF solid 1px;padding-left: 3px;" id="job_description_detail"></td>
                        </tr>
                        <tr>
                            <td style="width: 10%;height: 35px;border: #DFDFDF solid 1px;background: #F5F5F5;padding-left: 3px;color: #999999;text-align: center;">完成要求</td>
                            <td colspan="3" style="width: 90%;height: 35px;border: #DFDFDF solid 1px;padding-left: 3px;" id="complete_requirements_detail"></td>
                        </tr>
                        <tr>
                            <td style="width: 10%;height: 35px;border: #DFDFDF solid 1px;background: #F5F5F5;padding-left: 3px;color: #999999;text-align: center;">备注</td>
                            <td colspan="3" style="width: 90%;height: 35px;border: #DFDFDF solid 1px;padding-left: 3px;" id="note_detail"></td>
                        </tr>
                        <tr>
                            <td style="width: 10%;height: 70px;border: #DFDFDF solid 1px;background: #F5F5F5;padding-left: 3px;color: #999999;text-align: center;">附件</td>
                            <td colspan="3" style="width: 90%;height: 70px;border: #DFDFDF solid 1px;padding-left: 3px;" id="file_detail">
                            </td>
                        </tr>

                        <tr>
                            <td colspan="4" style="width: 100%;height: 50px;border: none;"></td>
                        </tr>
                        <tr>
                            <td colspan="4" style="width: 100%;height: 40px;line-height: 40px;text-align: center;"><h3>工作进展</h3></td>
                        </tr>
                    </table>
                    <table id="detail_body" style="width: 94%;">

                    </table>
                </div>

                <div id="flow_chart_detail" style="width: 100%;padding-bottom: 20px;padding-left: 3%;margin: 0;min-height: 600px;max-height: 700px;overflow: auto;display: none;justify-content: center;align-items: center;flex-direction: column;">

                </div>
            </div>
        </div>
    </div>

    <div id="staff-select" class="shade" style="z-index: 10100">
        <div id="staff-model" style="width: 100%;height: 100%;position: absolute;">
            <div style="width: 900px;height: 500px;background: #F5F5F5;z-index: 10000;position: absolute;top: 50%;left: 50%;transform:translate(-50%,-50%);border-radius: 3px;border: #dfdfdf solid 1px;">
                <div id="staff-box" style="width: 100%;height: 40px;background: #f4f7fa;cursor: move;border-top-left-radius: 5px;border-top-right-radius: 5px;border-bottom: #dfdfdf solid 1px;">
                    <div style="width: 20%;margin-left: 1%;display: inline-block;line-height: 40px;font-size: 14px;">
                        选择人员
                    </div>
                    <span onclick="close_model()" style="float: right;padding-right: 2%;cursor: pointer;line-height: 37px;">
                        <i class="iconfont icon-quchu"></i>
                    </span>
                </div>
                <div style="height: 460px;width: 100%;border-bottom: #dfdfdf solid 1px;">
                    <div style="width: 70px;height: 100%;border-right: #cfcfcf solid 1px;display: inline-block;vertical-align: top;">
                        <div id="dep" class="navigation navigation_color" onclick="change_navigation(this)">部门</div>
                        <div id="limits" class="navigation" onclick="change_navigation(this)">权限</div>
                        <div id="fun" class="navigation" onclick="change_navigation(this)">职能</div>
                    </div>
                    <div style="width: 200px;height: 100%;border-right: #cfcfcf solid 1px;display: inline-block;vertical-align: top;">
                        <div style="width: 100%;height: 50px;line-height: 50px;">
                            <input id="SearchDep" onkeydown="SearchDepartment()" class="search_input" type="text" placeholder="搜索" autocomplete="off" style="width: 90%;">
                        </div>
                        <div id="SecondaryNavigation" style="width: 100%;height: 403px;line-height: 50px;overflow: auto;"></div>
                    </div>
                    <div style="width: 200px;height: 100%;border-right: #cfcfcf solid 1px;display: inline-block;vertical-align: top;">
                        <div style="width: 100%;height: 50px;line-height: 50px;">
                            <input type="checkbox" id="select-all" onclick="SelectAll(this)">
                            <input id="SearchPeo" onkeydown="SearchProple()" class="search_input" type="text" placeholder="搜索" autocomplete="off" style="width: 90%;">
                        </div>
                        <div id="ThreeNavigation" style="width: 100%;height: 403px;line-height: 50px;overflow: auto;"></div>
                    </div>
                    <div style="width: 410px;height: 100%;display: inline-block;vertical-align: top;overflow: auto">
                        <div style="width: 100%;height: 40px;text-align: left;font-size: 14px;line-height: 40px;">
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;已选 <span id="selected-number">0</span> 人
                        </div>
                        <div id="selected-div" style="width: 100%;font-size: 14px;height: 370px;overflow: auto;line-height: 20px;">

                        </div>
                        <div style="width: 100%;font-size: 14px;height: 40px;text-align: center;">
                            <button id="finish_with" onclick="IdentifyPersonnel()" style="width: 100px;height: 30px;line-height: 25px;text-align: center;letter-spacing: 5px;border-radius: 3px;border: #cfcfcf solid 1px;font-size: 14px;cursor: pointer;margin-top: 10px;">完成</button>
                            <button onclick="close_model()" style="margin-left: 15px;width: 100px;height: 30px;line-height: 25px;text-align: center;color: #0abb78;letter-spacing: 5px;border-radius: 3px;font-size: 14px;border: #cfcfcf solid 1px;cursor: pointer;margin-top: 10px;">取消</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div id="selection-office" class="office-shade">
        <div id="office-model">
            <!-- 标题 -->
            <div id="office-title">
                <h5 style="line-height: 40px;width: 15%;margin-left: 1%;display: inline-block;font-size: 14px;">选择科室</h5>
                <span onclick="close_office_models()" style="float: right;line-height: 50px;padding-right: 2%;cursor: pointer;"><i class="iconfont icon-quchu"></i></span>
            </div>
            <hr>
            <div style="width: 55%;height: 350px;vertical-align: top;left: 0;display: inline-block;border-right: #cfcfcf solid 1px;">
                <div style="width: 100%;height: 50px;line-height: 50px;padding-left: 2%;">
                    <input id="search_data1" onkeydown="search_dep()" class="search-input" type="text" placeholder="搜索" autocomplete="off">
                </div>
                <div id="processed" style="width: 100%;height: 300px;overflow: auto;">
                    {% for company in company_list %}
                        <div style="width: 100%;height: 30px;line-height: 30px;font-size: 14px;color: #0b0b0b;">
                            <input class="check_box1" id="check-{{ company.id }}" type="checkbox" onclick="check_dep_ff('{{ company.name }}', 'check-{{ company.id }}', false)"> {{ company.name }}
                        </div>
                    {% endfor %}
                </div>
            </div>

            <div style="width: 43%;height: 360px;vertical-align: top;left: 0;display: inline-block;">
                <div style="width: 100%;height: 50px;line-height: 50px;padding-left: 2%;font-size: 14px;">
                    已选择科室
                </div>
                <div id="processed_prople" style="width: 100%;height: 265px;overflow: auto;padding-left: 2%;">

                </div>
                <div style="width: 100%;height: 40px;text-align: center;">
                    <button id="summit_button" style="border-radius: 2px;height: 30px;margin-top: 5px;border: #1E90FF solid 1px;background: #1E90FF;color: white;width: 80px;letter-spacing: 4px;font-size: 14px;">
                        提交
                    </button>
                    <button onclick="close_office_models()" style="border-radius: 2px;height: 30px;margin-top: 5px;border: #cfcfcf solid 1px;width: 80px;letter-spacing: 4px;margin-left: 15px;font-size: 14px;">
                        取消
                    </button>
                </div>
            </div>
        </div>
    </div>

    <div id="job_schedule" class="shade" style="z-index: 10111;">
        <div id="schedule_models" style="width: 100%;height: 100%;position: absolute;">
            <div style="width: 400px;background: white;z-index: 10000;position: absolute;top: 50%;left: 50%;transform:translate(-50%,-50%);border-radius: 3px;border: #dfdfdf solid 1px;">
                <div id="schedule_models_title" style="width: 100%;height: 40px;background: white;cursor: move;border-top-left-radius: 5px;border-top-right-radius: 5px;text-align: center;line-height: 40px;">
                    <span id="feedback_title" style="font-size: 18px;"></span>
                    <span onclick="close_schedule()" style="float: right;padding-right: 2%;cursor: pointer;"><i class="iconfont icon-quchu"></i></span>
                </div>

                <div style="width: 100%;border-bottom: #cfcfcf solid 1px;padding-bottom: 20px;margin: 0;padding-right: 2%;padding-left: 2%;">
                    <p><span style="color: red;">*</span> <span id="feedback_span"></span></p>
                    <textarea name="" id="opinion_detail" style="width: 96%;height: 100px;border: #CCCCCC solid 1px;outline: none;"></textarea>
                </div>

                <div style="width: 100%;height: 38px;text-align: center;">
                    <button id="confirm" style="width: 100px;height: 28px;margin-top: 5px;border: #2db7f5 solid 1px;background: #2db7f5;color: white;letter-spacing: 5px;border-radius: 3px;">确认</button>
                    <button onclick="close_schedule()" style="width: 100px;height: 28px;margin-top: 5px;border: #CCCCCC solid 1px;background: #CCCCCC;letter-spacing: 5px;margin-left: 15px;border-radius: 3px;">取消</button>
                </div>
            </div>
        </div>
    </div>
{% endblock %}

{% block script %}
    <script src="../../static/system_setup/creat_from/js/jquery-1.10.2.js"></script>
    <script src="../../static/administrative/layDate-v5.0.9/laydate/laydate.js"></script>
    <script type="text/javascript" src="../../static/public_file/js/DepartmentSelectionMultiple1.js"></script>
    <script src="../../static/public_file/js/PersonnelChoosersNew.js" type="text/javascript" charset="gb2312"></script>
    <script>
        window.onload = function () {
            document.getElementById("loading").style.display = "none";
            document.getElementById("personage").className = "add_class";
            document.getElementById("supervision_inspection_management").className = "add-nav-active";
        };

        laydate.render({
            elem: '#start_time', //指定元素
            type: 'date',
            format: 'yyyy-MM-dd'
        });

        laydate.render({
            elem: '#end_time', //指定元素
            type: 'date',
            format: 'yyyy-MM-dd'
        });

        function choose_performance_type(ele, type_number) {
            var performance_obj = document.getElementsByClassName("performance");
            for (var i=0; i<performance_obj.length; i++) {
                performance_obj[i].className = "performance";
            }
            ele.className = "performance performance_active";

            if (type_number === 1) {
                window.location.href = "work_supervision_list.html";
            }else if (type_number === 3) {
                window.location.href = "my_need_do.html";
            }else if (type_number === 4) {
                window.location.href = "my_already_done.html";
            }else if (type_number === 5) {
                window.location.href = "work_report.html";
            }else {
                window.location.href = "my_conscientious.html";
            }
        }

        let job_models_title = document.querySelector("#job_models_title");
        let job_models = document.querySelector("#job_models");

        job_models_title.addEventListener("mousedown", function (e) {
            let x = e.pageX - job_models.offsetLeft;
            let y = e.pageY - job_models.offsetTop;

            document.addEventListener("mousemove", move);
            function move(e) {
                job_models.style.left = e.pageX - x + 'px';
                job_models.style.top = e.pageY - y + 'px';
            }

            document.addEventListener("mouseup", function (e) {
                document.removeEventListener("mousemove", move);
            })
        });

        function onclick_upload_file() {
            document.getElementById("regular_main_body").click();
        }

        function upload_accessory() {
            var form = new FormData();
            var files = document.getElementById("regular_main_body").files[0];
            creat_table(files.name)
        }

        function creat_table(file_name) {
            var html_str = `
                <div style="width: 100%;height: 40px;line-height: 40px;">
                    <div style="width: 79%;height: 100%;display: inline-block;vertical-align: top;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">
                        <a target='_blank' href="javascript:;">`+file_name+`</a>
                    </div>
                    <div onclick="RemoveTr(this)" style="width: 18%;height: 100%;display: inline-block;vertical-align: top;text-align: center;font-size: 12px;cursor: pointer;color: red;">
                        删除
                    </div>
                </div>
            `
            $("#upload_file_list").append(html_str)
        }

        function RemoveTr(_this) {
            var parentNode = _this.parentNode;
            parentNode.remove()
        }

        function IdentifyPersonnel(obj_id) {
            var prople_list = [];
            var selected_personnel_list = document.getElementsByClassName('selected-personnel');
            for (var i=0; i<selected_personnel_list.length; i++) {
                prople_list.push(selected_personnel_list[i].innerText)
            }
            if (obj_id === 'referee') {
                var currt_flow_id = document.getElementById('referee').name
                schedule_confirm(currt_flow_id, 'referee', prople_list.join())
                return false
            }
            document.getElementById(obj_id).value = prople_list.join();
            close_model()
        }

        function show_model() {
            document.getElementById("addForm-fenfa").style.display="table-row";
        }

        function close_models1() {
            document.getElementById("addForm-fenfa").style.display = "none";
        }

        function summit_val(ele_id) {
            var processed_prople = document.getElementsByClassName("selected-department");
            if (processed_prople.length === 0){
                alert("请选择拟稿科室！");
                return false
             }
            var dep_list=[];
            for (var i=0; i<processed_prople.length; i++) {
                dep_list.push(processed_prople[i].innerText)
            }
            document.getElementById(ele_id).value=dep_list.join();
            close_office_models();
        }

        function search_dep() {
            var company_list = {{ company_list | safe }};
            var search_keyword = document.getElementById("search_data1").value;
            var processed = document.getElementById("processed");
            processed.innerHTML = "";
            for (var h=0; h<company_list.length; h++){
                if (company_list[h]["name"].indexOf(search_keyword) !== -1){
                    console.log(company_list[h]["name"])
                    var div_tag = document.createElement("div");div_tag.className="div_clase";
                    div_tag.innerHTML = '<input class="check_box1" id="check-'+company_list[h]["id"]+'" type="checkbox" onclick="check_dep_ff(\''+company_list[h]["name"]+'\', \'check-'+company_list[h]["id"]+'\', false)"> '+ company_list[h]["name"];
                    processed.appendChild(div_tag)
                }
            }
        }

        function submit_summary() {
            var form = new FormData();
            var title = document.getElementById("title").value;                         // 工作来源
            var company = document.getElementById("company").value;                     // 责任科室
            var responsible_person = document.getElementById("responsible_person").value;           // 负责人
            var start_time = document.getElementById("start_time").value;                               // 开始时间
            var end_time = document.getElementById("end_time").value;                // 结束时间
            var job_description = document.getElementById("job_description").value;         // 工作描述
            var complete_requirements = document.getElementById("complete_requirements").value;         // 完成要求
            var note = document.getElementById("note").value;                                   // 备注
            var files = document.getElementById("regular_main_body").files;
            if (!title) {
                alert("请输入工作来源！")
                return false
            }
            if (!company) {
                alert("请输入责任科室！")
                return false
            }
            if (!responsible_person) {
                alert("请输入责任人！")
                return false
            }
            if (!start_time) {
                alert("请输入开始时间！")
                return false
            }
            if (!end_time) {
                alert("请输入结束时间！")
                return false
            }
            if (!job_description) {
                alert("请输入工作描述！")
                return false
            }
            if (!complete_requirements) {
                alert("请输入完成要求！")
                return false
            }
            document.getElementById("loading").style.display = "inline-block";
            form.append("title", title);
            form.append("company", company);
            form.append("responsible_person", responsible_person);
            form.append("start_time", start_time);
            form.append("end_time", end_time);
            form.append("job_description", job_description);
            form.append("complete_requirements", complete_requirements);
            form.append("note", note);
            form.append("fj_number", '{{ uuid | safe }}');
            if (files.length) {
                form.append("file", files[0]);
            }
            var xhr = new XMLHttpRequest();
            xhr.open('post', "/supervision-inspection/work_supervision_list.html", true);
            xhr.send(form);
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        document.getElementById("loading").style.display = "none";
                        var JsonDate = JSON.parse(xhr.responseText);
                        alert("创建成功！")
                        window.location.reload();
                    }
                }
            };
        }

        function views_detail(flow_id) {
            var form = new FormData();
            form.append("id", flow_id)
            document.getElementById("loading").style.display = "inline-block";
            document.getElementById("job_detail").style.display="table-row";
            var xhr = new XMLHttpRequest();
            xhr.open('post', "/supervision-inspection/work_supervision_detail", true);
            xhr.send(form);
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        document.getElementById("loading").style.display = "none";
                        var JsonDate = JSON.parse(xhr.responseText);
                        document.getElementById("title_detail").innerText = JsonDate["obj_detail"]["title"];
                        document.getElementById("company_detail").innerText = JsonDate["obj_detail"]["company"];
                        document.getElementById("responsible_person_detail").innerText = JsonDate["obj_detail"]["responsible_person"];
                        document.getElementById("start_time_detail").innerText = JsonDate["obj_detail"]["start_time"];
                        document.getElementById("end_time_detail").innerText = JsonDate["obj_detail"]["end_time"];
                        document.getElementById("job_description_detail").innerText = JsonDate["obj_detail"]["job_description"];
                        document.getElementById("complete_requirements_detail").innerText = JsonDate["obj_detail"]["complete_requirements"];
                        document.getElementById("note_detail").innerText = JsonDate["obj_detail"]["note"];

                        var file_tubiao = ""
                        if (JsonDate["files"]["file_name"].split(".").slice(-1)[0] === "doc" || JsonDate["files"]["file_name"].split(".").slice(-1)[0] === "docx"){
                            file_tubiao='<img src="../../static/correspondence/img/word%20(3).png" alt="" style="width: 50px;height: 50px;">';
                        }else if (JsonDate["files"]["file_name"].split(".").slice(-1)[0] === "pdf" || JsonDate["files"]["file_name"].split(".").slice(-1)[0] === "PDF"){
                            file_tubiao='<img src="../../static/correspondence/img/pdf.png" alt="" style="width: 50px;height: 50px;">';
                        }else if (JsonDate["files"]["file_name"].split(".").slice(-1)[0] === "xls" || JsonDate["files"]["file_name"].split(".").slice(-1)[0] === "xlsx"){
                            file_tubiao='<img src="../../static/correspondence/img/Excel写入-选中.png" alt="" style="width: 50px;height: 50px;">'
                        }else if (JsonDate["files"]['file_name'].split(".").slice(-1)[0] === "PNG" || JsonDate["files"]['file_name'].split(".").slice(-1)[0] === "png")  {
                            file_tubiao='<img src="../../static/correspondence/img/PNG%20(1).png" alt="" style="width: 50px;height: 50px;">'
                        }else {
                            file_tubiao = ""
                        }

                        document.getElementById("file_detail").innerHTML = "<a target='_blank' href='" + JsonDate["files"]["file_path"] + "'>" + file_tubiao + "<span>" + JsonDate["files"]["file_name"] + "</span></a>"

                        document.getElementById("detail_body").innerHTML = "";
                        for (var i=0; i<JsonDate["FeedbackList"].length; i++) {
                            var ReceiptFile = "";
                            if (JsonDate["FeedbackList"][i]["file_path"].split(",").length > 1) {
                                var file_list = JsonDate["FeedbackList"][i]["file_path"].split(",");
                                for (var tt=0; tt<file_list.length; tt++) {
                                    if (file_list[tt].split(".").slice(-1)[0] === "doc" || file_list[tt].split(".").slice(-1)[0] === "docx"){
                                        var aaaaaaa=`<a href="`+file_list[tt]+`"><img src="../../static/correspondence/img/word%20(3).png" alt="" style="width: 50px;height: 50px;"></a>`;
                                    }else if (file_list[tt].split(".").slice(-1)[0] === "pdf" || file_list[tt].split(".").slice(-1)[0] === "PDF"){
                                        aaaaaaa=`<a target="_blank" href="`+file_list[tt]+`"><img src="../../static/correspondence/img/pdf.png" alt="" style="width: 50px;height: 50px;"></a>`;
                                    }else if (file_list[tt].split(".").slice(-1)[0] === "xls" || file_list[tt].split(".").slice(-1)[0] === "xlsx"){
                                        aaaaaaa=`<a href="`+file_list[tt]+`"><img src="../../static/correspondence/img/Excel写入-选中.png" alt="" style="width: 50px;height: 50px;"></a>`
                                    }else if (file_list[tt].split(".").slice(-1)[0] === "PNG" || file_list[tt].split(".").slice(-1)[0] === "png") {
                                        aaaaaaa = `<a href="` + file_list[tt] + `"><img src="../../static/correspondence/img/PNG%20(1).png" alt="" style="width: 50px;height: 50px;"></a>`
                                    }else {
                                        aaaaaaa = "";
                                    }
                                    ReceiptFile = ReceiptFile + aaaaaaa;
                                }

                            }else {
                                if (JsonDate["FeedbackList"][i]["file_path"].split(".").slice(-1)[0] === "doc" || JsonDate["FeedbackList"][i]["file_path"].split(".").slice(-1)[0] === "docx"){
                                    ReceiptFile=`<a href="`+JsonDate["FeedbackList"][i]["file_path"]+`"><img src="../../static/correspondence/img/word%20(3).png" alt="" style="width: 50px;height: 50px;"></a>`;
                                }else if (JsonDate["FeedbackList"][i]["file_path"].split(".").slice(-1)[0] === "pdf" || JsonDate["FeedbackList"][i]["file_path"].split(".").slice(-1)[0] === "PDF"){
                                    ReceiptFile=`<a target="_blank" href="`+JsonDate["FeedbackList"][i]["file_path"]+`"><img src="../../static/correspondence/img/pdf.png" alt="" style="width: 50px;height: 50px;"></a>`;
                                }else if (JsonDate["FeedbackList"][i]["file_path"].split(".").slice(-1)[0] === "xls" || JsonDate["FeedbackList"][i]["file_path"].split(".").slice(-1)[0] === "xlsx"){
                                    ReceiptFile=`<a href="`+JsonDate["FeedbackList"][i]["file_path"]+`"><img src="../../static/correspondence/img/Excel写入-选中.png" alt="" style="width: 50px;height: 50px;"></a>`
                                }else if (JsonDate["FeedbackList"][i]["file_path"].split(".").slice(-1)[0] === "PNG" || JsonDate["FeedbackList"][i]["file_path"].split(".").slice(-1)[0] === "png") {
                                    ReceiptFile = `<a href="` + JsonDate["FeedbackList"][i]["file_path"] + `"><img src="../../static/correspondence/img/PNG%20(1).png" alt="" style="width: 50px;height: 50px;"></a>`
                                }else {
                                    ReceiptFile = "";
                                }
                            }
                            var html_str = `
                                <tr style="width: 100%;">
                                    <td style="width: 25%;height: 50px;border: #DFDFDF solid 1px;text-align: center;">`+JsonDate["FeedbackList"][i]["time"]+`</td>
                                    <td style="width: 25%;height: 50px;border: #DFDFDF solid 1px;text-align: center;font-size: 18px;"><strong>`+JsonDate["FeedbackList"][i]["name"]+`(`+JsonDate["FeedbackList"][i]["state"]+`)`+`</strong></td>
                                    <td style="width: 25%;height: 50px;border: #DFDFDF solid 1px;padding-left: 1%;">`+JsonDate["FeedbackList"][i]["audit_note"]+`</td>
                                    <td style="width: 25%;height: 50px;border: #DFDFDF solid 1px;padding-left: 1%;">`+ReceiptFile+`</td>
                                </tr>
                            `
                            $("#detail_body").append(html_str);
                        }

                        var FlowChartDetail = document.getElementById('flow_chart_detail');
                        FlowChartDetail.innerHTML = "";

                        var start_flow = `
                            <div style="min-width: 100px;border-radius: 10px;background: #2db7f5;border: #2db7f5 solid 1px;height: 40px;line-height: 40px;color: white;margin-top: 15px;text-align: center;display: block">开&nbsp;&nbsp;&nbsp;始</div>
                        `
                        $("#flow_chart_detail").append(start_flow)
                        if (JsonDate["flow_dict"]['one']['status'] === 'unaudit') {
                            var one_flow = `
                                <div><i class="iconfont icon-xia--jiantou" style="font-size: 30px;color: #838B8B;"></i></div>
                                <div style="min-width: 100px;border-radius: 10px;background: #838B8B;border: #838B8B solid 1px;height: 40px;text-align: center;font-size: 10px;">责任人<br>(`+JsonDate["flow_dict"]['one']['name']+`)</div>
                            `
                        }else {
                            one_flow = `
                                <div><i class="iconfont icon-xia--jiantou" style="font-size: 30px;color: #2db7f5;"></i></div>
                                <div style="min-width: 100px;border-radius: 10px;background: #2db7f5;border: #2db7f5 solid 1px;height: 40px;text-align: center;font-size: 10px;color:white;">责任人<br>(`+JsonDate["flow_dict"]['one']['name']+`)</div>
                            `
                        }
                        $("#flow_chart_detail").append(one_flow)
                        if (JsonDate["flow_dict"].hasOwnProperty("two")) {
                            if (JsonDate["flow_dict"]['two']['status'] === 'unaudit') {
                                var two_flow = `
                                    <div><i class="iconfont icon-xia--jiantou" style="font-size: 30px;color: #838B8B;"></i></div>
                                    <div style="min-width: 100px;border-radius: 10px;background: #838B8B;border: #838B8B solid 1px;height: 40px;text-align: center;font-size: 10px;">分管院长<br>(`+JsonDate["flow_dict"]['two']['name']+`)</div>
                                `
                            }else {
                                two_flow = `
                                    <div><i class="iconfont icon-xia--jiantou" style="font-size: 30px;color: #2db7f5;"></i></div>
                                    <div style="min-width: 100px;border-radius: 10px;background: #2db7f5;border: #2db7f5 solid 1px;height: 40px;text-align: center;font-size: 10px;color:white;">分管院长<br>(`+JsonDate["flow_dict"]['two']['name']+`)</div>
                                `
                            }
                            $("#flow_chart_detail").append(two_flow)
                        }
                        if (JsonDate["flow_dict"]['three']['status'] === 'unaudit') {
                            var three_flow = `
                                <div><i class="iconfont icon-xia--jiantou" style="font-size: 30px;color: #838B8B;"></i></div>
                                <div style="min-width: 100px;border-radius: 10px;background: #838B8B;border: #838B8B solid 1px;height: 40px;text-align: center;font-size: 10px;">医院质量管理办公室<br>(`+JsonDate["flow_dict"]['three']['name']+`)</div>
                            `
                        }else {
                            three_flow = `
                                <div><i class="iconfont icon-xia--jiantou" style="font-size: 30px;color: #2db7f5;"></i></div>
                                <div style="min-width: 100px;border-radius: 10px;background: #2db7f5;border: #2db7f5 solid 1px;height: 40px;text-align: center;font-size: 10px;color:white;">医院质量管理办公室<br>(`+JsonDate["flow_dict"]['three']['name']+`)</div>
                            `
                        }
                        $("#flow_chart_detail").append(three_flow)
                        if (JsonDate["flow_dict"].hasOwnProperty("four")) {
                            if (JsonDate["flow_dict"]['four']['status'] === 'unaudit') {
                                var four_flow = `
                                    <div><i class="iconfont icon-xia--jiantou" style="font-size: 30px;color: #838B8B;"></i></div>
                                    <div style="min-width: 100px;border-radius: 10px;background: #838B8B;border: #838B8B solid 1px;height: 40px;text-align: center;font-size: 10px;">院领导<br>(`+JsonDate["flow_dict"]['four']['name']+`)</div>
                                `
                            }else {
                                four_flow = `
                                    <div><i class="iconfont icon-xia--jiantou" style="font-size: 30px;color: #2db7f5;"></i></div>
                                    <div style="min-width: 100px;border-radius: 10px;background: #2db7f5;border: #2db7f5 solid 1px;height: 40px;text-align: center;font-size: 10px;color:white;">院领导<br>(`+JsonDate["flow_dict"]['four']['name']+`)</div>
                                `
                            }
                            $("#flow_chart_detail").append(four_flow)
                        }
                        if (JsonDate["flow_dict"]['five']['status'] === 'unaudit') {
                            var five_flow = `
                                <div><i class="iconfont icon-xia--jiantou" style="font-size: 30px;color: #838B8B;"></i></div>
                                <div style="min-width: 100px;border-radius: 10px;background: #838B8B;border: #838B8B solid 1px;height: 40px;text-align: center;font-size: 10px;">发起科室归档<br>(`+JsonDate["flow_dict"]['five']['name']+`)</div>
                                <div><i class="iconfont icon-xia--jiantou" style="font-size: 30px;color: #838B8B;"></i></div>
                                <div style="min-width: 100px;border-radius: 10px;background: #838B8B;border: #838B8B solid 1px;height: 40px;line-height: 40px;text-align: center;">结&nbsp;&nbsp;&nbsp;束</div>
                            `
                        }else {
                            five_flow = `
                                <div><i class="iconfont icon-xia--jiantou" style="font-size: 30px;color: #2db7f5;"></i></div>
                                <div style="min-width: 100px;border-radius: 10px;background: #2db7f5;border: #2db7f5 solid 1px;height: 40px;text-align: center;font-size: 10px;color:white;">发起科室归档<br>(`+JsonDate["flow_dict"]['five']['name']+`)</div>
                                <div><i class="iconfont icon-xia--jiantou" style="font-size: 30px;color: #2db7f5;"></i></div>
                                <div style="min-width: 100px;border-radius: 10px;background: #2db7f5;border: #2db7f5 solid 1px;height: 40px;line-height: 40px;color: white;text-align: center;">结&nbsp;&nbsp;&nbsp;束</div>
                            `
                        }
                        $("#flow_chart_detail").append(five_flow)
                    }
                }
            };
        }

        function close_job_detail() {
            document.getElementById("job_detail").style.display = "none";
        }

        function scrollConversationScreen() {
            $('#selected-div').scrollTop($('#selected-div')[0].scrollHeight);
        }

        function schedule_confirm(flow_id, type, prople_list) {
            var audit_note = document.getElementById("opinion_detail").value;
            if (type === "back" && !audit_note) {
                alert("请填写退回意见！");
                return false
            }
            var form = new FormData();
            form.append("id", flow_id)
            form.append("type", type)
            form.append("audit_note", audit_note)
            form.append("referee", prople_list)
            document.getElementById("loading").style.display = "inline-block";
            var xhr = new XMLHttpRequest();
            xhr.open('post', "/supervision-inspection/work_operations", true);
            xhr.send(form);
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        document.getElementById("loading").style.display = "none";
                        var JsonDate = JSON.parse(xhr.responseText);
                        if (JsonDate['code'] === 200) {
                            alert("操作成功！")
                            window.location.reload();
                        }else {
                            alert(JsonDate['message'])
                        }
                    }
                }
            };
        }

        function EndJob(flow_id, type) {
            if (type === "approval") {
                document.getElementById("feedback_title").innerText = "工作批复"
                document.getElementById("feedback_span").innerText = "批复意见"
            }else {
                document.getElementById("feedback_title").innerText = "工作退回"
                document.getElementById("feedback_span").innerText = "退回意见"
            }
            document.getElementById("job_schedule").style.display = "table-row";
            document.getElementById("confirm").setAttribute("onclick", "schedule_confirm('"+flow_id+"', '" + type + "', '')")
        }

        function close_schedule() {
            document.getElementById("job_schedule").style.display = "none";
        }

        function change_top(top_type) {
            if (top_type === '1') {
                document.getElementById('top_detail').className = 'top_class top_class_active';
                document.getElementById('top_flow').className = 'top_class';
                document.getElementById('flow_detail').style.display = 'block';
                document.getElementById('flow_chart_detail').style.display = 'none';
            }else {
                var this_div_obj = document.getElementById('this_div');
                document.getElementById('this_div').style.height = this_div_obj.offsetHeight+"px";
                document.getElementById('top_detail').className = 'top_class';
                document.getElementById('top_flow').className = 'top_class top_class_active';
                document.getElementById('flow_detail').style.display = 'none';
                document.getElementById('flow_chart_detail').style.display = 'flex';
            }
        }

        function change_page_size(page_number=1) {
            {#var page_size = document.getElementById('page-size').value;#}
            const url = new URL(window.location.href);
            // 创建URLSearchParams对象
            const params = new URLSearchParams(url.search);
            // 设置某个参数的值
            params.set('page', page_number);
            {#params.set('page_size', page_size);#}
            url.search = params.toString();
            window.location.href = url.href;
        }
    </script>
{% endblock %}
